package com.xuanxing123.model;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;

@Entity
@Table(name="selection_product",catalog="xuanxing")
@Searchable
@XmlRootElement
public class SelectionProduct extends BaseObject implements Serializable {
    private Long id;
    private Selection selection;
    private Product product;
    private Integer rateBudget;
    private Integer rateBrand;
    private Integer rateModule;
    private Integer rateIndustry;
    private Integer rateMarketPositioning;
    private Integer rateCompanyType;
    private Integer rateImplCycle;
    private Integer rateTotal;

    @Id
    @GeneratedValue(strategy=IDENTITY)
    @SearchableId
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="selection_id", nullable=false)
    public Selection getSelection() {
        return this.selection;
    }
    
    public void setSelection(Selection selection) {
        this.selection = selection;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="product_id", nullable=false)
    public Product getProduct() {
        return this.product;
    }
    
    public void setProduct(Product product) {
        this.product = product;
    }
    
    @Column(name="rate_budget")
    @SearchableProperty
    public Integer getRateBudget() {
        return this.rateBudget;
    }
    
    public void setRateBudget(Integer rateBudget) {
        this.rateBudget = rateBudget;
    }
    
    @Column(name="rate_brand")
    @SearchableProperty
    public Integer getRateBrand() {
        return this.rateBrand;
    }
    
    public void setRateBrand(Integer rateBrand) {
        this.rateBrand = rateBrand;
    }
    
    @Column(name="rate_module")
    @SearchableProperty
    public Integer getRateModule() {
        return this.rateModule;
    }
    
    public void setRateModule(Integer rateModule) {
        this.rateModule = rateModule;
    }
    
    @Column(name="rate_industry")
    @SearchableProperty
    public Integer getRateIndustry() {
        return this.rateIndustry;
    }
    
    public void setRateIndustry(Integer rateIndustry) {
        this.rateIndustry = rateIndustry;
    }
    
    @Column(name="rate_market_positioning")
    @SearchableProperty
    public Integer getRateMarketPositioning() {
        return this.rateMarketPositioning;
    }
    
    public void setRateMarketPositioning(Integer rateMarketPositioning) {
        this.rateMarketPositioning = rateMarketPositioning;
    }
    
    @Column(name="rate_company_type")
    @SearchableProperty
    public Integer getRateCompanyType() {
        return this.rateCompanyType;
    }
    
    public void setRateCompanyType(Integer rateCompanyType) {
        this.rateCompanyType = rateCompanyType;
    }
    
    @Column(name="rate_impl_cycle")
    @SearchableProperty
    public Integer getRateImplCycle() {
        return this.rateImplCycle;
    }
    
    public void setRateImplCycle(Integer rateImplCycle) {
        this.rateImplCycle = rateImplCycle;
    }
    
    @Column(name="rate_total")
    @SearchableProperty
    public Integer getRateTotal() {
        return this.rateTotal;
    }
    
    public void setRateTotal(Integer rateTotal) {
        this.rateTotal = rateTotal;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SelectionProduct pojo = (SelectionProduct) o;

        if (selection != null ? !selection.equals(pojo.selection) : pojo.selection != null) return false;
        if (product != null ? !product.equals(pojo.product) : pojo.product != null) return false;
        if (rateBudget != null ? !rateBudget.equals(pojo.rateBudget) : pojo.rateBudget != null) return false;
        if (rateBrand != null ? !rateBrand.equals(pojo.rateBrand) : pojo.rateBrand != null) return false;
        if (rateModule != null ? !rateModule.equals(pojo.rateModule) : pojo.rateModule != null) return false;
        if (rateIndustry != null ? !rateIndustry.equals(pojo.rateIndustry) : pojo.rateIndustry != null) return false;
        if (rateMarketPositioning != null ? !rateMarketPositioning.equals(pojo.rateMarketPositioning) : pojo.rateMarketPositioning != null) return false;
        if (rateCompanyType != null ? !rateCompanyType.equals(pojo.rateCompanyType) : pojo.rateCompanyType != null) return false;
        if (rateImplCycle != null ? !rateImplCycle.equals(pojo.rateImplCycle) : pojo.rateImplCycle != null) return false;
        if (rateTotal != null ? !rateTotal.equals(pojo.rateTotal) : pojo.rateTotal != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (selection != null ? selection.hashCode() : 0);
        result = 31 * result + (product != null ? product.hashCode() : 0);
        result = 31 * result + (rateBudget != null ? rateBudget.hashCode() : 0);
        result = 31 * result + (rateBrand != null ? rateBrand.hashCode() : 0);
        result = 31 * result + (rateModule != null ? rateModule.hashCode() : 0);
        result = 31 * result + (rateIndustry != null ? rateIndustry.hashCode() : 0);
        result = 31 * result + (rateMarketPositioning != null ? rateMarketPositioning.hashCode() : 0);
        result = 31 * result + (rateCompanyType != null ? rateCompanyType.hashCode() : 0);
        result = 31 * result + (rateImplCycle != null ? rateImplCycle.hashCode() : 0);
        result = 31 * result + (rateTotal != null ? rateTotal.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("selection").append("='").append(getSelection()).append("', ");
        sb.append("product").append("='").append(getProduct()).append("', ");
        sb.append("rateBudget").append("='").append(getRateBudget()).append("', ");
        sb.append("rateBrand").append("='").append(getRateBrand()).append("', ");
        sb.append("rateModule").append("='").append(getRateModule()).append("', ");
        sb.append("rateIndustry").append("='").append(getRateIndustry()).append("', ");
        sb.append("rateMarketPositioning").append("='").append(getRateMarketPositioning()).append("', ");
        sb.append("rateCompanyType").append("='").append(getRateCompanyType()).append("', ");
        sb.append("rateImplCycle").append("='").append(getRateImplCycle()).append("', ");
        sb.append("rateTotal").append("='").append(getRateTotal()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
